/*
 * Copyright [2022] [https://www.xiaonuo.vip]
 *
 * Snowy采用APACHE LICENSE 2.0开源协议，您在使用过程中，需要注意以下几点：
 *
 * 1.请不要删除和修改根目录下的LICENSE文件。
 * 2.请不要删除和修改Snowy源码头部的版权声明。
 * 3.本项目代码可免费商业使用，商业使用请保留源码和相关描述文件的项目出处，作者声明等。
 * 4.分发源码时候，请注明软件出处 https://www.xiaonuo.vip
 * 5.不可二次分发开源参与同类竞品，如有想法可联系团队xiaonuobase@qq.com商议合作。
 * 6.若您的项目无法满足以上几点，需要更多功能代码，获取Snowy商业授权许可，请在官网购买授权，地址为 https://www.xiaonuo.vip
 */
package com.xieq.dota.modular.group.controller;

import com.xieq.dota.modular.group.param.GroupAddParam;
import com.xieq.dota.modular.group.param.GroupEditParam;
import com.xieq.dota.modular.group.param.GroupIdParam;
import com.xieq.dota.modular.group.service.GroupService;
import com.xieq.dota.modular.match.param.*;
import com.xieq.dota.modular.match.result.GroupDrawResult;
import com.xieq.dota.modular.matchplayer.entity.MatchPlayer;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import vip.xiaonuo.common.annotation.CommonLog;
import vip.xiaonuo.common.pojo.CommonResult;

import java.util.List;

/**
 * 分组表控制器
 *
 * @author xieq
 * @date  2025/11/10 09:51
 */
@Tag(name = "分组表控制器")
@RestController
@Validated
public class GroupController {

    @Resource
    private GroupService groupService;

    /**
     * 添加分组表
     *
     * @author xieq
     * @date  2025/11/10 09:51
     */
    @Operation(summary = "添加分组表")
    @CommonLog("添加分组表")
    @PostMapping("/dota/group/add")
    public CommonResult<String> add(@RequestBody @Valid GroupAddParam groupAddParam) {
        groupService.add(groupAddParam);
        return CommonResult.ok();
    }

    /**
     * 删除分组表
     *
     * @author xieq
     * @date  2025/11/10 09:51
     */
    @Operation(summary = "删除分组表")
    @CommonLog("删除分组表")
    @PostMapping("/dota/group/delete")
    public CommonResult<String> delete(@RequestBody @Valid @NotEmpty(message = "集合不能为空")
                                                   List<GroupIdParam> groupIdParamList) {
        groupService.delete(groupIdParamList);
        return CommonResult.ok();
    }

    /**
     * 获取分组表详情
     *
     * @author xieq
     * @date  2025/11/10 09:51
     */
    @Operation(summary = "获取分组表详情")
    @GetMapping("/dota/group/detail")
    public CommonResult<List<MatchGroupDetail>> detail(@Valid String matchId) {
        return CommonResult.data(groupService.detail(matchId));
    }


    /**
     * 抽取选手
     *
     * @author xieq
     * @date 2025/11/07
     */
    @Operation(summary = "抽取选手")
    @PostMapping("/dota/group/drawPlayers")
    public CommonResult<List<GroupDrawResult>> drawPlayers(@RequestBody @Valid GroupDrawParam param) {
        return CommonResult.data(groupService.drawPlayers(param));
    }

    /**
     * 卡池剩余选手列表
     *
     * @author xieq
     * @date 2025/11/10
     */
    @Operation(summary = "卡池剩余选手列表")
    @PostMapping("/dota/group/cardRemainPlayers")
    public CommonResult<List<GroupDrawResult>> cardRemainPlayers(@RequestBody @Valid GroupDrawParam param) {
        return CommonResult.data(groupService.cardRemainPlayer(param));
    }

    /**
     * 获取可选队长列表
     *
     * @author xieq
     * @date 2025/11/10
     */
    @Operation(summary = "获取可选队长列表")
    @PostMapping("/dota/group/captainList")
    public CommonResult<List<GroupCaptainResult>> captainList(@RequestBody @Valid GroupCaptainParam param) {
        return CommonResult.data(groupService.captainList(param));
    }

    /**
     * 设置队长
     *
     * @author xieq
     * @date 2025/11/10
     */
    @Operation(summary = "设置队长")
    @PostMapping("/dota/group/update")
    public CommonResult<Boolean> update(@RequestBody @Valid GroupAddPlayerParam param) {
        return CommonResult.data(groupService.update(param));
    }

    /**
     * 设置道具
     *
     * @author xieq
     * @date 2025/11/10
     */
    @Operation(summary = "设置道具")
    @PostMapping("/dota/group/edit")
    public CommonResult<Boolean> edit(@RequestBody @Valid GroupEditParam param) {
        groupService.edit(param);
        return CommonResult.ok();
    }
}
